// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package ecommerce.intrmanufacture;

import include.get_sql.getInsertSql;
import include.nseer_cookie.counter;
import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		try
		{
			HttpSession dbSession = request.getSession();
			JspFactory _jspxFactory = JspFactory.getDefaultFactory();
			javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
			javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
			HttpSession session = request.getSession();
			nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 design_db1 = new nseer_db_backup1(dbApplication);
			ValidataNumber validata = new ValidataNumber();
			ValidataTag vt = new ValidataTag();
			counter count = new counter(dbApplication);
			getInsertSql getInsertSql = new getInsertSql();
			if (design_db.conn((String)dbSession.getAttribute("unit_db_name")) && design_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String product_ID = request.getParameter("product_ID");
				String choice = request.getParameter("choice");
				String bodyb = new String(request.getParameter("promotion3").getBytes("UTF-8"), "UTF-8");
				String promotion = exchange.toHtml(bodyb);
				String bodyd = new String(request.getParameter("opinion3").getBytes("UTF-8"), "UTF-8");
				String opinion = exchange.toHtml(bodyd);
				String checker_ID = request.getParameter("checker_ID");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String lately_change_time = request.getParameter("lately_change_time");
				String file_change_amount = request.getParameter("file_change_amount");
				int change_amount = Integer.parseInt(file_change_amount) + 1;
				String column_group = getInsertSql.sql((String)dbSession.getAttribute("unit_db_name"), "design_file");
				String sql6 = (new StringBuilder("select * from ecommerce_workflow where object_ID='")).append(product_ID).append("' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("')) and type_id='04'").toString();
				ResultSet rs6 = design_db.executeQuery(sql6);
				if (!rs6.next() && vt.validata((String)session.getAttribute("unit_db_name"), "design_file", "product_ID", product_ID, "excel_tag3").equals("1"))
				{
					if (choice != null)
					{
						if (choice.equals(""))
						{
							String sql = (new StringBuilder("update design_file set promotion='")).append(promotion).append("',opinion='").append(opinion).append("',excel_tag3='9' where product_ID='").append(product_ID).append("'").toString();
							design_db.executeUpdate(sql);
							sql = (new StringBuilder("update ecommerce_workflow set check_tag='9',checker_ID='")).append(checker_ID).append("',checker='").append(checker).append("',check_time='").append(check_time).append("' where product_ID='").append(product_ID).append("' and config_id='").append(config_id).append("' and type_id='04'").toString();
							design_db.executeUpdate(sql);
						} else
						{
							sql6 = (new StringBuilder("select * from ecommerce_workflow where object_ID='")).append(product_ID).append("' and config_id<'").append(config_id).append("' and config_id>='").append(choice).append("' and type_id='04'").toString();
							String sql;
							for (rs6 = design_db.executeQuery(sql6); rs6.next(); design_db1.executeUpdate(sql))
								sql = (new StringBuilder("update ecommerce_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("'").toString();

						}
						response.sendRedirect("ecommerce/oem/check_delete_ok_a.jsp");
					} else
					{
						response.sendRedirect((new StringBuilder("ecommerce/oem/check_delete_ok_b.jsp?product_ID=")).append(product_ID).append("&config_id=").append(config_id).toString());
					}
				} else
				{
					response.sendRedirect("ecommerce/oem/check_delete_ok_c.jsp");
				}
				design_db.commit();
				design_db1.commit();
				design_db.close();
				design_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
